package 力扣._00周赛._414周赛.问题3;

public class Solution {
    public String getBinS(int n) {
        StringBuilder s = new StringBuilder();
        while (n > 0) {
            if (n % 2 == 0)
                s.insert(0, '0');
            else
                s.insert(0, 1);
            n /= 2;
        }
        return s.toString();
    }

    public String convertDateToBinary(String date) {
        String[] strings = date.split("-");
        int y = Integer.parseInt(strings[0]);
        int m = Integer.parseInt(strings[1]);
        int d = Integer.parseInt(strings[2]);
        return getBinS(y) + "-" + getBinS(m) + "-" + getBinS(d);
    }

    public static void main(String[] args) {
        String s = new Solution().convertDateToBinary("2080-02-29");
        System.out.println(s);
    }
}
